package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.service.UserSearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("api/v1/history")
public class UserSearchHistoryController {

    @Autowired
    UserSearchHistoryService userSearchHistoryService;

    /**
     * 加载用户的 搜索记录  列表
     * @return
     */
    @PostMapping("load")
    public ResponseResult load(){
        return userSearchHistoryService.load();
    }


    /**
     * 删除搜索记录
     * @param dto
     * @return
     */
    @PostMapping("del")
    public ResponseResult del(@RequestBody HistorySearchDto dto){
        return userSearchHistoryService.del(dto);
    }
}
